package com.ruoyi.app.controller;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.app.domain.DebtRecordsFile;
import com.ruoyi.app.service.IDebtRecordsFileService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 供应商信息Controller
 * 
 * @author ruoyi
 * @date 2024-12-29
 */
@RestController
@RequestMapping("/debt/debtRecordsFile")
public class DebtRecordsFileController extends BaseController
{
    @Autowired
    private IDebtRecordsFileService debtRecordsFileService;

    /**
     * 查询供应商信息列表
     */
    @PreAuthorize("@ss.hasPermi('debt:debtRecordsFile:list')")
    @GetMapping("/list")
    public TableDataInfo list(DebtRecordsFile debtRecordsFile)
    {
        startPage();
        List<DebtRecordsFile> list = debtRecordsFileService.selectDebtRecordsFileList(debtRecordsFile);
        return getDataTable(list);
    }

    /**
     * 导出供应商信息列表
     */
    @PreAuthorize("@ss.hasPermi('debt:debtRecordsFile:export')")
    @Log(title = "供应商信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DebtRecordsFile debtRecordsFile)
    {
        List<DebtRecordsFile> list = debtRecordsFileService.selectDebtRecordsFileList(debtRecordsFile);
        ExcelUtil<DebtRecordsFile> util = new ExcelUtil<DebtRecordsFile>(DebtRecordsFile.class);
        util.exportExcel(response, list, "供应商信息数据");
    }

    /**
     * 获取供应商信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('debt:debtRecordsFile:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(debtRecordsFileService.selectDebtRecordsFileById(id));
    }

    /**
     * 新增供应商信息
     */
    @PreAuthorize("@ss.hasPermi('debt:debtRecordsFile:add')")
    @Log(title = "供应商信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody DebtRecordsFile debtRecordsFile)
    {
        return toAjax(debtRecordsFileService.save(debtRecordsFile));
    }

    /**
     * 修改供应商信息
     */
    @PreAuthorize("@ss.hasPermi('debt:debtRecordsFile:edit')")
    @Log(title = "供应商信息", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody DebtRecordsFile debtRecordsFile)
    {
        return toAjax(debtRecordsFileService.updateById(debtRecordsFile));
    }

    /**
     * 删除供应商信息
     */
    @PreAuthorize("@ss.hasPermi('debt:debtRecordsFile:remove')")
    @Log(title = "供应商信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        List<String> objects = Arrays.asList(ids);
        return toAjax(debtRecordsFileService.removeByIds(objects));
    }
}
